package com.neusoft.ai.chat.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zzc
 * @since 2025/6/13 下午1:36
 */
@RestController
public class ChatController {

    private final ChatClient client;

    public ChatController(ChatClient.Builder  clientClientBuilder){
        this.client = clientClientBuilder.build();
    }

    //1.简单对话
    @GetMapping("/chat")
    public String chat(@RequestParam(value = "message", defaultValue = "你是谁") String message) {
        //prompt()提示词
        return client.prompt()
                //用户输入信息
                .user(message)
                //请求大模型
                .call()
                //返回文本
                .content();
    }

    //
}
